<include file="Public:header" />
<form method="post" action="" name="myform" id="myform">
<input name="id" type="hidden" value="{$info['id']}">
  <fieldset>
    <legend>基本信息</legend>
    <table class="table_form" width="100%" cellspacing="0">
      <tbody>
        <tr>
          <th>角色名称：</th>
          <td><input name="name" id="name" class="input-text" type="text" size="20" value="{$info.name}">
            <span class="onShow"></span></td>
        </tr>
        <tr class="last">
          <th>启用状态：</th>
          <td style="text-align:left">
          	<input type="radio" name="status" value="1" checked/>启用
            <input type="radio" name="status" value="0" />停用
		  </td>
        </tr>
        <tr>
          <th>排序：</th>
          <td><input name="sort" id="sort" class="input-text" type="text" size="10" value="{$info.sort}">
            注：数值越小越靠前</td>
        </tr>
        <tr class="last">
          <th>备注：</th>
          <td colspan="3"><textarea name="remark" id="remark" class="input-textarea" cols="75" rows="4">{$info.remark}</textarea></td>
        </tr>
      </tbody>
    </table>
  </fieldset>
  <volist name="nodeList" id="vo">
  <fieldset>
    <legend>{$vo.title}</legend>
    <table class="table_form" width="100%" cellspacing="0">
      <tbody>
      	<tr><th width="90">全选：</th><td><input name="nodeIdArr[{$vo.id}]" class="appNodeId" type="checkbox" value="{$vo.id}" title="{$vo.checked}"></td></tr>
		<volist name="vo['model']" id="v" >
        <tr>
          <th width="90"><input name="nodeIdArr[{$vo.id}][{$v.id}]" type="checkbox" value="{$v.id}" class="modelNodeId" title="{$v.checked}" style="float:left;" > {$v.title}：</th>
          <td>
            	<volist name="v['action']" id="cv">
                    <input name="nodeIdArr[{$vo.id}][{$v.id}][{$cv['id']}]" type="checkbox" value="{$cv['id']}" title="{$cv.checked}" class="actionNodeId" />
                    <span style="margin-left:5px; margin-right:10px; ">{$cv.title}</span>
                </volist>
          </td>
        </tr>
        </volist>
      </tbody>
    </table>
  </fieldset>
  </volist>
  <input type="submit" value="提交" class="dialog"  id="dosubmit">
</form>
</body>
</html>
<script type="text/javascript">
$(function(){
	var  status = "{$info.status}";
	if(status==0){
		$('input[name="status"]').attr("checked",'0');
	}

	$('#myform').ajaxForm({
		beforeSubmit:  checkForm,
		success:       complete,
		dataType: 'json'
	});
	function checkForm(){
		if($('#name').val().length < 2){
			$('#name').focus();
			checkInfo('name','分组名称不得少于2个字符');
			return false;
		}else{
			return true;
		}
	}

	var origin = $.artDialog.open.origin;

    function complete(data){
		msg(data.info,data.status);
		if(data.status)  setTimeout(function(){origin.location.reload();},1000);
		closeWin(1500);
    }

	//全选
	$(".appNodeId").change(function(){
		var appNodeId = $(this).attr('checked');
		if(appNodeId==true){
			 $(":checkbox").each(function() {
				this.checked=true;
			});
		}else{
			$(":checkbox").each(function() {
				this.checked=false;
			});
		}
	})

	//选择
	$(".modelNodeId").change(function(){
		if( $(this).attr('checked')==true ){
			$(this).parent().nextAll().find(":checkbox").each(function() {
				this.checked=true;
			});
		}else{
			$(this).parent().nextAll().find(":checkbox").each(function() {
				this.checked=false;
			});
		}
	})

	//设置默认权限
	$(".actionNodeId").each(function() {
    	var title = $(this).attr('title');
		if( title!='' ){
			this.checked=true;
		}
    });


})
</script>
